/*
 *------------------------------------------------------------------------------
 * @File      :    eos_default_panel.c
 * @Date      :    2021-3-20
 * @Author    :    lomboswer <lomboswer@lombotech.com>
 * @Brief     :    Source file for MDP(Media Development Platform).
 *
 * Copyright (C) 2020-2021, LomboTech Co.Ltd. All rights reserved.
 *------------------------------------------------------------------------------
 */

#include <fcntl.h>
#include "ei_comm_panel.h"
#include "panel_usr.h"
#include "ei_math.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

#define EOS_WIDTH	(720)
#define EOS_HEIGHT	(1280)
#define EOS_HBP		(40)
#define EOS_HFP		(40)
#define EOS_HSW		(20)
#define EOS_HACT	(EOS_WIDTH)
#define EOS_VBP		(7)
#define EOS_VFP		(20)
#define EOS_VSW		(6)
#define EOS_VACT	(EOS_HEIGHT)
#define EOS_VT		(EOS_VBP + EOS_VFP + EOS_VSW + EOS_VACT)
#define EOS_DCLK	(59400000 / 1000)
#define DCS_MDELAY_FLAG (0)

static VO_PUB_ATTR_S eos_default_config = {
    .enIntfType = VO_INTF_MIPI,
    .enIntfSync = VO_OUTPUT_USER,

    .stSyncInfo.lane_id = {0, 1, 2, 3},
    .stSyncInfo.output_mode = OUTPUT_MODE_DSI_VIDEO,
    .stSyncInfo.output_format = OUT_FORMAT_RGB_24_BIT,
    .stSyncInfo.video_mode =  NON_BURST_MODE_SYNC_PULSES,
    .stSyncInfo.bIop = 1,
    .stSyncInfo.u16Hfb = EOS_HFP,
    .stSyncInfo.u16Hpw = EOS_HSW,
    .stSyncInfo.u16Hbb = EOS_HBP,
    .stSyncInfo.u16Hact = EOS_HACT,
    .stSyncInfo.u16Vfb = EOS_VFP,
    .stSyncInfo.u16Vpw = EOS_VSW,
    .stSyncInfo.u16Vbb = EOS_VBP,
    .stSyncInfo.u16Vact = EOS_VACT,
    .stSyncInfo.u32Pclk = EOS_DCLK, /* 59.4 kHz */
};

static unsigned char eos_default_init_code[] = {
    2, 0x00, 0x00,
    4, 0xff, 0x12, 0x89, 0x01,
    2, 0x00, 0x80,
    3, 0xff, 0x12, 0x89,
    2, 0x00, 0x90,
    2, 0xff, 0xb0,
    2, 0x00, 0x80,
    9, 0xc0, 0x4a, 0x00, 0x10, 0x10, 0x96, 0x01, 0x68, 0x40,
    2, 0x00, 0x90,
    4, 0xc0, 0x3b, 0x01, 0x09,
    2, 0x00, 0x8c,
    2, 0xc0, 0x00,
    2, 0x00, 0x80,
    2, 0xc1, 0x33,
    2, 0x00, 0x85,
    4, 0xc5, 0x0a, 0x0a, 0x46,
    2, 0x00, 0x00,
    3, 0xd8, 0x27, 0x27,
    2, 0x00, 0x01,
    2, 0xd9, 0x7d,
    2, 0x00, 0x84,
    2, 0xC4, 0x02,
    2, 0x00, 0x93,
    2, 0xC4, 0x04,
    2, 0x00, 0x96,
    2, 0xF5, 0xE7,
    2, 0x00, 0xA0,
    2, 0xF5, 0x4A,
    2, 0x00, 0x8a,
    2, 0xc0, 0x11,
    2, 0x00, 0x83,
    2, 0xF5, 0x81,
    2, 0x00, 0x90,
    3, 0xc4, 0x96, 0x05,
    2, 0x00, 0x80,
    16, 0xcb, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    2, 0x00, 0x90,
    8, 0xcb, 0xFC, 0xFC, 0xFC, 0x00, 0x14, 0x14, 0x14,
    2, 0x00, 0x80,
    15, 0xcc, 0x02, 0x0A, 0x0C, 0x0E, 0x10, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    2, 0x00, 0x90,
    16, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x1D, 0x06, 0x01,
        0x09, 0x0B, 0x0d, 0x0F, 0x00, 0x00, 0x00,
    2, 0x00, 0xa0,
    14, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x1E, 0x1D, 0x05,
    2, 0x00, 0xb0,
    15, 0xcc, 0x05, 0x0F, 0x0D, 0x0B, 0x09, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    2, 0x00, 0xc0,
    16, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x1E, 0x01, 0x06,
        0x10, 0x0E, 0x0C, 0x0A, 0x00, 0x00, 0x00,
    2, 0x00, 0xd0,
    14, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x1D, 0x1E, 0x02,
    2, 0x00, 0x80,
    7, 0xce, 0x87, 0x03, 0x10, 0x86, 0x00, 0x00,
    2, 0x00, 0x90,
    10, 0xce, 0x34, 0xff, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
    2, 0x00, 0xa0,
    16, 0xce, 0x30, 0x83, 0x88, 0x00, 0x20, 0x00, 0x82, 0x87,
        0x00, 0x81, 0x86, 0x00, 0x80, 0x85, 0x00,
    2, 0x00, 0xb0,
    16, 0xce, 0x30, 0x00, 0x84, 0x00, 0x20, 0x00, 0x01, 0x83,
        0x00, 0x02, 0x82, 0x00, 0x03, 0x81, 0x00,
    2, 0x00, 0xE0,
    9, 0xCE, 0x0A, 0x04, 0xFC, 0x00, 0x00, 0x0A, 0x04, 0xFC,
    2, 0x00, 0xF0,
    7, 0xCE, 0x01, 0x20, 0x01, 0x01, 0x00, 0x00,
    2, 0x00, 0x00,
    17, 0xE1, 0x00, 0x16, 0x26, 0x37, 0x47, 0x65, 0x64, 0x7d,
        0x76, 0x62, 0x69, 0x50, 0x38, 0x21, 0x13, 0x00,
    2, 0x00, 0x00,
    17, 0xE2, 0x00, 0x16, 0x26, 0x37, 0x47, 0x65, 0x64, 0x7d,
        0x76, 0x62, 0x69, 0x50, 0x38, 0x21, 0x13, 0x00,
    2, 0x00, 0x00,
    4, 0xff, 0xff, 0xff, 0xff,
    1,  0x11,
    0, 200,
    1,  0x29,
    0, 120,
};

EI_S32 panel_eos_default_get_panel_attr(PANEL_TYPE_E enPanelType, PANEL_TYPE_ATTR_S *pstPanelAttr)
{
    pstPanelAttr->stVoPubAttr = eos_default_config;

    return EI_SUCCESS;
}

EI_S32 panel_eos_default_get_panel_init_code(PANEL_TYPE_E enPanelType, PANEL_INIT_CODE_TYPE *init, EI_U32 *pLen)
{
    *init = &eos_default_init_code[0];
    *pLen = EI_ARRAY_SIZE(eos_default_init_code);
    return EI_SUCCESS;
}

PANEL_OBJ_S stPanelEosDefaultObj = {
    .pfnGetPanelAttrByPanel = panel_eos_default_get_panel_attr,
    .pfnGetPanelInitCodeByPanel = panel_eos_default_get_panel_init_code,
};

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

